<?php 
$userData = $this->loggedInUser();
if ($userData == null) {
//Not loggedIn
	?>
	
	<div id="homeAd">
	<div id="homeL"></div>
	<div id="homeR"></div>
</div>
<div id="homeSignup">
<a id="signup" href="<?php echo $this->url(array('controller'=>'user','action'=>'register'),"default",true);?>"></a>
</div>

<div id="homeInfo">
<div id="homeInfoInner">
<div id="homeLeft">
<h1 class="home">What's Happening around this area ... </h1>
<ul class="activities">
<?php echo $this->activityList($this->activities,true); ?>
</ul>
</div>

<div id="homeRight" style="float:right;">


<h1 class="home">News from Us</h1>
<ul class="thumbnails">
<?php echo $this->blogRss();?>
</ul>

<?php
 echo $this->bookThumbnailList($this->topBooks); ?>


<?php
echo $this->userThumbnailList($this->topUsers); ?>

</div>
</div>

<?php }else {
//LoggedIn

	$user = $this->user;
	$userbook_cnt = count(User::getBooks($user,UserBookStatus::AVAILABLE));
?>
<div id="homeLeft">
<?php if($userbook_cnt==0 || empty($user->introduction)){ ?>
<div id="tips"> ^_^
<?php if($userbook_cnt==0){ //No book added ?>
Haven't added a book yet? Try to <a href="<?php echo $this->url(array('controller'=>'book','action'=>'fetch'),"default",true); ?>">add a book</a>, let others know!
<?php } else if(empty($user->introduction)){?>
Tell others more about you, e.g Where do you live? What kind of books are you interested? <br />Go to 
<a href="<?php echo $this->url(array('controller'=>'user','action'=>'settings'),"default",true); ?>">Settings</a> page to edit.
<?php }?>
</div>
<?php }?>
<h1 class="home">What's Happening around this area ... </h1>
<ul class="activities">
<?php echo $this->activityList($this->activities,true); ?>
</ul>
</div>

<div id="homeRight" style="float:right;">
<h1 class="home"><span style="float:left;"><?php echo $user->name;?></span>
<a href="<?php echo $this->url(array('controller'=>'user','action'=>'profile'),"default",true); ?>" style="float:right;font-size:11px;letter-spacing:0;line-height:11px;margin-top:11px;">More</a></h1>
<ul class="thumbnails">
<div class="dotline"></div>
<div class="actImg">
	<img src="<?php echo $this->userThumbnail($this->user); ?>"/>
	<?php 
$uc = User::checkUserAuthProvider($user, AuthProvider::FACEBOOK);
if (!empty($uc)) {
?><a target="_blank" id="fbIcon" title="<?php echo $user->name;?> has connected with Facebook, isn't he/she more trustworthy? Click to check out!" href="http://www.facebook.com/profile.php?id=<?php echo $uc->auth_uid;?>">
fb</a>
<?php }?>
</div>
<div style="float:left;margin-left:3px;width:175px;font-size:11px;padding-top:5px;line-height:20px;">
<?php echo $this->userLocation($this->user); ?>
<br />
<a href="<?php echo $this->url(array("controller"=>"user", "action"=>"profilebooks", "uid"=>$this->user->id), null, true);?>">
Books (<?php echo $userbook_cnt;?>)</a><br />
<a id="addABookSmall"  href="<?php echo $this->url(array('controller'=>'book','action'=>'fetch'),"default",true); ?>">Add a Book</a>
</div>
<div class="dotline"></div>
</ul>

<h1 class="home" style="margin-top: 25px;">News from Us</h1>
<ul class="thumbnails">
<?php  echo $this->blogRss();?>
</ul>

<?php
 echo $this->bookThumbnailList($this->topBooks); ?>

<?php
echo $this->userThumbnailList($this->topUsers); ?>

</div>
</div>
<?php }?>